/**
 *
 * @param {string} cookies_str cookie字符串
 * @param {string} domain 域名
 * @returns { name, value, domain, path }
 */
export function fmtCookie(cookies_str, domain) {
  let cookies = cookies_str.split(";").map((pair) => {
    let name = pair.trim().slice(0, pair.trim().indexOf("="));
    let value = pair.trim().slice(pair.trim().indexOf("=") + 1);
    let path = "/";
    return { name, value, domain, path };
  });
  //   console.log("cookie", cookies);
  return cookies;
}

/**
 *
 * @param {number} time 延迟时间
 * @returns
 */
export function delay(time) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve();
    }, time);
  });
}
